<template>
  <view>
    <z-paging ref="pagingRef" @query="queryList" v-model="list">
      <template #top>
        <view style="height: 100px"></view>
      </template>
      <view v-for="(item,index) in list" :key="index">
        <view @click="toQuery(item)">
        <ArticleItem2 :article-item="item"></ArticleItem2>
        </view>
      </view>
    </z-paging>
  </view>
</template>

<script setup lang="ts">
import {ref} from "vue";
import api from "@/api";
import {useUserStore} from "@/store";
import ArticleItem2 from "@/components/common/item/ArticleItem2.vue";

const userStore = useUserStore()

const list = ref([])


const pagingRef = ref()
const andParams = ref({})
const orParams = ref({})
const orderParams = ref({
  createTime: '2',
})
const queryList = (pageNo: any, pageSize: any) => {
  api.article.list({
    pageNo: pageNo,
    pageSize: pageSize,
    andParams: JSON.stringify(andParams.value),
    orParams: JSON.stringify(orParams.value),
    orderParams: JSON.stringify(orderParams.value),
  }).then(res => {
    if (res && res.data.code === 0) {
      let tmp = res.data.data.records
      pagingRef.value.complete(tmp);
    }
  })
}

const toQuery = (item: any) => {
  uni.navigateTo({
    url: '/pages/common/article/article?articleInfo=' + encodeURIComponent(JSON.stringify(item))
  })
}


</script>

<style scoped>

</style>